//
//  MahjongGameCVC.m
//  Mahjong
//
//  Created by 饶首建 on 17/6/29.
//  Copyright © 2017年 com.ikamobile.com. All rights reserved.
//

#import "MahjongGameCVC.h"
#import "MahjongGameTVC.h"

@interface MahjongGameCVC()<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

static NSString *kMahjongGameTVC = @"kMahjongGameTVC";

@implementation MahjongGameCVC

- (void)awakeFromNib {
    [super awakeFromNib];
    [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([MahjongGameTVC class]) bundle:nil] forCellReuseIdentifier:kMahjongGameTVC];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.tableFooterView = [UIView new];
}

- (void)setGameModel:(GameModel *)gameModel{
    _gameModel = gameModel;
    [_tableView reloadData];
}

#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _gameModel.resultArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MahjongGameTVC *cell = [tableView dequeueReusableCellWithIdentifier:kMahjongGameTVC forIndexPath:indexPath];
    cell.gameModel = _gameModel;
    cell.owner = _owner;
    if (indexPath.row == 3) {
        cell.notShowLine = YES;
    }
    cell.resultModel = _gameModel.resultArr[indexPath.row];
    cell.tagClickBlock = ^(id data){
        if (_getTagClickBlock) {
            _getTagClickBlock(data);
        }
    };
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return (self.frame.size.height - 40)/4;
}


#pragma mark - UITableViewDelegate


@end
